#include<stdio.h>

int get_month_day(int y,int m)
{
	int arr[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int ret =  arr[m]; 
	
	if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
    {
    	if( m == 2)
    	{
    		ret ++;
		}
    	
	}

     return ret;
}


int main()
{
    int y,m;
	scanf("%d%d",&y,&m);
	
	int day = get_month_day(y,m);
	printf("%d\n",day); 
	
	return 0;
}
